<template>
  <a-modal
    :title="title"
    :width="1000"
    :visible="visible"
    :confirmLoading="confirmLoading"
    switchFullscreen
    @cancel="handleCancel"
    :class="editType =='detail'?'pic-preview':''">
    <template slot="footer">
        <a-button key="back" @click="handleCancel">
          {{editType =='detail'?'关闭':'取消'}}
        </a-button>
        <a-button key="submit" type="primary" :loading="loading" @click="handleSave">
          临时保存
        </a-button>
        <a-button key="submit" type="primary" :loading="loading" @click="handleOk">
          提交
        </a-button>
      </template>
    <a-spin :spinning="confirmLoading">
      <a-form :form="form">
        <a-row>
          <a-col :span="8">
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="统一信用代码">
          <a-input @blur="findCode" :disabled="editType=='detail'" placeholder="请输入统一信用代码" v-decorator="['CompanyCode', validatorRules.companycode]" />
        </a-form-item>
      </a-col>
      <a-col :span="8">
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="公司全称">
          <a-input :disabled="editType=='detail'" style="width:120px;margin-right:5px" placeholder="请输入公司全称" v-decorator="['CompanyName', validatorRules.companyname]" />
          <a-button size="small" @click="getData" :disabled="isLoadingData">同步</a-button>
        </a-form-item>
        </a-col>
      <a-col :span="8">
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="公司简称">
          <a-input :disabled="editType=='detail'" placeholder="请输入公司简称" v-decorator="['CompanyAbbr', validatorRules.companyabbr]" />
        </a-form-item>
        </a-col>
      <a-col :span="24">
        <a-form-item class="labelColMax"
          label="一句话简介">
          <a-input :disabled="editType=='detail'" type="textarea" placeholder="请输入一句话简介" v-decorator="['CompanyBrief', {}]" />
        </a-form-item>
        </a-col>
      <a-col :span="8">
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="法人代表">
          <!-- <a-input placeholder="请选择法人代表" v-show v-decorator="['LegalPerson']"></a-input> -->
          <a-input placeholder="请选择法人代表" @click="showCommonUserModal" v-decorator="['LegalPerson',{}]"></a-input>
          <!-- <a-select :disabled="editType=='detail'" show-search :filter-option="filterOption" placeholder="请选择" v-decorator="['LegalPerson', {}]" >
            <a-select-option value="">请选择</a-select-option>
            <a-select-option :value="item.PersonalName" v-for="(item,index) in personData">{{item.PersonalName}}</a-select-option>
          </a-select> -->
        </a-form-item>
        </a-col>
      <a-col :span="8">
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="成立日期">
          <a-date-picker :disabled="editType=='detail'" placeholder="请输入成立日期" v-decorator="['RegisteredDate', {}]" />
        </a-form-item>
        </a-col>
      <a-col :span="8">
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="注册币种">
          <a-select placeholder="请输入注册币种" v-decorator="['CurrencyTypeId', {}]" >
            <a-select-option value="">请选择</a-select-option>
            <a-select-option :value="item.BaseInfoId" v-for="(item,index) in currentTypeData">{{item.Value}}</a-select-option>
          </a-select>
        </a-form-item>
        </a-col>
      <a-col :span="8">
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="注册资本">
          <a-input-number :disabled="editType=='detail'" style="width:calc(100% - 35px);margin-right:5px" placeholder="请输入注册资本" v-decorator="['RegisteredAmt', {}]" />万
        </a-form-item>
        </a-col>
        
      <a-col :span="8">
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="实缴资本">
          <a-input-number :disabled="editType=='detail'" style="width:calc(100% - 35px);margin-right:5px" placeholder="请输入实缴资本" v-decorator="['PaidinAmt', {}]" />万
        </a-form-item>
        </a-col>
      <a-col :span="8">
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="经营状态">
          <a-select :disabled="editType=='detail'" placeholder="请选择经营状态" v-decorator="['OperationStatusId', {}]" >
            <a-select-option value="">请选择</a-select-option>
            <a-select-option :value="item.BaseInfoId" v-for="(item,index) in opeStatusData">{{item.Value}}</a-select-option>
          </a-select>
        </a-form-item>
        </a-col>
        <a-col :span="8">
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="注册省份">
          <a-select show-search :filter-option="filterOption" @change="getCityZc" :disabled="editType=='detail'" placeholder="请输入注册省份" v-decorator="['ProvinceId', {}]" >
            <a-select-option value="">请选择</a-select-option>
            <a-select-option :value="item.RegionId" v-for="(item,index) in provinceData">{{item.RegionName}}</a-select-option>
          </a-select>
        </a-form-item>
        </a-col>
      <a-col :span="8">
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="注册城市">
          <a-select :disabled="editType=='detail'" show-search :filter-option="filterOption" @change="changeCity" placeholder="请输入所在城市" v-decorator="['CityId', {}]" >
            <a-select-option value="">请选择</a-select-option>
            <a-select-option :value="item.RegionId" v-for="(item,index) in cityArrZc">{{item.RegionName}}</a-select-option>
          </a-select>
        </a-form-item>
        </a-col>
      
      <a-col :span="8">
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="注册区/县">
          <a-select :disabled="editType=='detail'" show-search :filter-option="filterOption" placeholder="请输入注册区/县" v-decorator="['RegisteredDistrictId', {}]" >
            <a-select-option value="">请选择</a-select-option>
            <a-select-option :value="item.RegionId" v-for="(item,index) in districtArr">{{item.RegionName}}</a-select-option>
          </a-select>
        </a-form-item>
        </a-col>
      <a-col :span="24">
        <a-form-item
          class="labelColMax"
          label="注册详细地址">
          <a-input :disabled="editType=='detail'" type="textarea" placeholder="请输入注册详细地址" v-decorator="['RegisteredAddress', {}]" />
        </a-form-item>
        </a-col>
        <a-col :span="8">
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="办公省份">
          <a-select show-search :filter-option="filterOption" @change="getCity" :disabled="editType=='detail'" placeholder="请输入办公省份" v-decorator="['OfficeProvinceId', {}]" >
            <a-select-option value="">请选择</a-select-option>
            <a-select-option :value="item.RegionId" v-for="(item,index) in provinceData">{{item.RegionName}}</a-select-option>
          </a-select>
        </a-form-item>
        </a-col>
      <a-col :span="8">
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="办公城市">
          <a-select :disabled="editType=='detail'" show-search :filter-option="filterOption" @change="changeOfficeCity" placeholder="请输入所在城市" v-decorator="['OfficeCityId', {}]" >
            <a-select-option value="">请选择</a-select-option>
            <a-select-option :value="item.RegionId" v-for="(item,index) in cityArr">{{item.RegionName}}</a-select-option>
          </a-select>
        </a-form-item>
      </a-col>
      <a-col :span="8">
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="办公区/县">
          <a-select :disabled="editType=='detail'" show-search :filter-option="filterOption" placeholder="请输入办公区/县" v-decorator="['OfficeDistrictId', {}]" >
            <a-select-option value="">请选择</a-select-option>
            <a-select-option :value="item.RegionId" v-for="(item,index) in districtOfficeArr">{{item.RegionName}}</a-select-option>
          </a-select>
        </a-form-item>
        </a-col>
      <a-col :span="24">
        <a-form-item
          class="labelColMax"
          label="办公详细地址">
          <a-input :disabled="editType=='detail'" type="textarea" placeholder="请输入办公详细地址" v-decorator="['OfficeAddress', {}]" />
        </a-form-item>
      </a-col>
      <a-col :span="8">
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="一级行业">
          <a-select :disabled="editType=='detail'" show-search :filter-option="filterOption" @change="getErjiIndustry" placeholder="请选择行业" v-decorator="['PrimaryIndustryId', {}]" >
            <a-select-option value="">请选择</a-select-option>
            <a-select-option :value="item.BaseIndustryId" v-for="(item,index) in industryData">{{item.Industry}}</a-select-option>
          </a-select>
        </a-form-item>
      </a-col>
      <a-col :span="8">

        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="二级行业">
          <a-select :disabled="editType=='detail'" show-search :filter-option="filterOption" @change="getSecondIndustry" placeholder="请选择行业" v-decorator="['IndustryId', {}]" >
            <a-select-option value="">请选择</a-select-option>
            <a-select-option :value="item.BaseIndustryId" v-for="(item,index) in secIndustryData">{{item.Industry}}</a-select-option>
          </a-select>
        </a-form-item>
        </a-col>
        <a-col :span="16">

        <a-form-item
          class="labelColMid"
          label="三级行业">
          <a-select mode="multiple" :disabled="editType=='detail'" show-search :filter-option="filterOption" placeholder="请选择子行业" v-decorator="['SubIndustry', {}]" >
            <a-select-option value="">请选择</a-select-option>
            <a-select-option :value="item.BaseIndustryId" v-for="(item,index) in secondIndustryData">{{item.Industry}}</a-select-option>
          </a-select>
        </a-form-item>
        </a-col>
      <a-col :span="24">
        <a-form-item
          class="labelColMax"
          label="行业标签">
          <a-select :disabled="editType=='detail'" mode="tags" placeholder="请输入行业标签" v-decorator="['IndustryTagId', {}]" >
            <a-select-option :value="item.IndustryTag" v-for="(item,index) in industryTagData">{{item.IndustryTag}}</a-select-option>
          </a-select>
        </a-form-item>
        </a-col>
        <a-col :span="24">
        <a-form-item
          class="labelColMax"
          label="资质标签">
          <a-select :disabled="editType=='detail'" mode="multiple" placeholder="请输入资质标签" v-decorator="['QualificationTag', {}]" >
            <a-select-option :value="item.Value" v-for="(item,index) in qualificationTagData">{{item.Value}}</a-select-option>
          </a-select>
        </a-form-item>
        </a-col>
        <a-col :span="8">
          <a-form-item
            :labelCol="labelCol"
            :wrapperCol="wrapperCol"
            label="园区类型">
            <a-select :disabled="editType=='detail'" show-search :filter-option="filterOption" @change="getParkFirst" placeholder="请选择园区类型" v-decorator="['HighteckParkId', {}]" >
              <a-select-option value="">请选择</a-select-option>
              <a-select-option :value="item.BaseInfoId" v-for="(item,index) in ParkTypeArr">{{item.Value}}</a-select-option>
            </a-select>
          </a-form-item>
        </a-col>
        <a-col :span="8">
          <a-form-item
            :labelCol="labelCol"
            :wrapperCol="wrapperCol"
            label="开发区">
            <a-select :disabled="editType=='detail'" show-search :filter-option="filterOption" placeholder="请选择开发区" v-decorator="['SubParkId', {}]" >
              <a-select-option value="">请选择</a-select-option>
              <a-select-option :value="item.BaseHighteckParkId" v-for="(item,index) in parkArrFirst">{{item.ParkName}}</a-select-option>
            </a-select>
          </a-form-item>
        </a-col>
        <a-col :span="8">
          <a-form-item
            :labelCol="labelCol"
            :wrapperCol="wrapperCol"
            label="产业园区">
            <a-select :disabled="editType=='detail'" show-search :filter-option="filterOption" placeholder="请选择产业区域" v-decorator="['IndustrialParkId', {}]" >
              <a-select-option value="">请选择</a-select-option>
              <a-select-option :value="item.BaseIndustrialParkId" v-for="(item,index) in IndusParkList">{{item.IndustrialParkName}}</a-select-option>
            </a-select>
          </a-form-item>
        </a-col>
        <!-- <a-col :span="8">
        
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="所属产业区域">
          <a-select :disabled="editType=='detail'" show-search :filter-option="filterOption" @change="getSecondPark" placeholder="请选择所属产业区域" v-decorator="['HighteckParkId', {}]" >
            <a-select-option value="">请选择</a-select-option>
            <a-select-option :value="item.BaseInfoId" v-for="(item,index) in parkArrFirst">{{item.Value}}</a-select-option>
          </a-select>
        </a-form-item>
        </a-col>
        
        <a-col :span="8">
        
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="所在园区">
          <a-select :disabled="editType=='detail'" show-search :filter-option="filterOption" placeholder="请选择所在产业园区" @change="changePark" v-decorator="['SubParkId', {}]" >
            <a-select-option value="">请选择</a-select-option>
            <a-select-option :value="item.BaseHighteckParkId" v-for="(item,index) in secondParkArr">{{item.ParkName}}</a-select-option>
          </a-select>
        </a-form-item>
        </a-col> -->
        <!-- <a-col :span="8">
        
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="所属开发区">
          <a-input disabled  v-decorator="['ParkTypeName', {}]" />
            
        </a-form-item>
        </a-col> -->
        
        <a-col :span="24">
        <a-form-item
          class="labelColMax"
          label="公司介绍">
          <a-input :disabled="editType=='detail'" type="textarea" placeholder="请输入公司介绍" v-decorator="['CompanyDepiction', {}]" />
        </a-form-item>
        </a-col>
      <a-col :span="24">
        <a-form-item
          class="labelColMax"
          label="团队描述">
          <a-input :disabled="editType=='detail'" type="textarea" placeholder="请输入团队描述" v-decorator="['TeamRemark', {}]" />
        </a-form-item>
        </a-col>
        <a-col :span="24">
        <a-form-item
          class="labelColMax"
          label="公司Logo">
          <a-upload
            name="file"
            :multiple="false"
            :accept="accept"
            :showUploadList="false"

            v-decorator="['FilesName', {}]"
            :beforeUpload="uploadPic">
            <a-button><a-icon type="upload"/>上传</a-button>
          </a-upload>
          <span style="margin-left:10px;">
            <template v-for="(item,index) in fileList">
              <img @click="picUrl = 'https://link.zhangtongshe.com'+item.url,showPic=true" style="width:80px;cursor: pointer;" :src="'https://link.zhangtongshe.com'+item.url">
              <a-icon style="cursor:pointer;margin-left:10px;" type="delete" @click="deleteFileObj(index)"/>
            </template>
            
          </span>
        </a-form-item>
        </a-col>
        <a-col :span="24">
        <a-form-item
          class="labelColMax"
          v-show
          label="图片">
          <a-input :disabled="editType=='detail'" placeholder="请输入团队描述" v-decorator="['CompanyLogo', {}]" />
        </a-form-item>
        </a-col>
      </a-row>
        <!-- <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="人员规模">
          <a-input placeholder="请输入人员规模" v-decorator="['staffsizeid', validatorRules.staffsizeid]" />
        </a-form-item>
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="纳税规模">
          <a-input placeholder="请输入纳税规模" v-decorator="['taxedsizeid', validatorRules.taxedsizeid]" />
        </a-form-item>
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="估值规模">
          <a-input placeholder="请输入估值规模" v-decorator="['valuationsizeid', validatorRules.valuationsizeid]" />
        </a-form-item>
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="融资轮次">
          <a-input placeholder="请输入融资轮次" v-decorator="['refinanceroundid', validatorRules.refinanceroundid]" />
        </a-form-item>
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="互动周期">
          <a-input placeholder="请输入互动周期" v-decorator="['interactivecycleid', validatorRules.interactivecycleid]" />
        </a-form-item>
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="服务状态">
          <a-input placeholder="请输入服务状态" v-decorator="['servicestatusid', validatorRules.servicestatusid]" />
        </a-form-item>
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="Linker">
          <a-input placeholder="请输入Linker" v-decorator="['linkerid', validatorRules.linkerid]" />
        </a-form-item>
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="最近更新人">
          <a-input placeholder="请输入最近更新人" v-decorator="['updatebyid', validatorRules.updatebyid]" />
        </a-form-item>
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="最近更新日期">
          <a-input placeholder="请输入最近更新日期" v-decorator="['ts', validatorRules.ts]" />
        </a-form-item>
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="状态">
          <a-input placeholder="请输入状态" v-decorator="['datastatus', validatorRules.datastatus]" />
        </a-form-item>
        <a-form-item
          :labelCol="labelCol"
          :wrapperCol="wrapperCol"
          label="互动标签">
          <a-input placeholder="请输入互动标签" v-decorator="['interactivetag', validatorRules.interactivetag]" />
        </a-form-item> -->
		
      </a-form>
    </a-spin>
    <a-modal :width="600" :visible="showPic" @cancel="showPic = false" class="pic-preview" title="查看大图">
      <img :src="picUrl" style="width:100%"/>
    </a-modal>
    <commonModal
      modalTitle="人员选择"
      rowKey="PersonalInfoId"
      ref="commonModalUser"
      @getCommonModalData="commonModalDataUser"
      :columns="tableColumnsUser"
      apiUrl="/personalInfo/queryRows"
      :searchArr="searchArrUser"></commonModal>
  </a-modal>
</template>

<script>
  import { httpAction,getAction } from '@/api/manage'
  import pick from 'lodash.pick'
  import moment from "moment"
  import commonModal from '@/components/commonModal'
  import axios from "axios"
  export default {
    name: "CompanyInfoModal",
    components:{
      commonModal
    },
    watch:{
      visible(newVal,oldVal){
        if(newVal){
          this.editType = sessionStorage.getItem('editType');
        }
      }
    },
    data () {
      return {
        isLoadingData: false,
        tableColumnsUser:[
          { title: '姓名', dataIndex: 'PersonalName' },
          { title: '性别', dataIndex: 'Gender_Value' },
        ],
        searchArrUser:[
          { label: '姓名', key: 'PersonalName' },
        ],
        picUrl:'',
        showPic:false,
        parkArrFirst:[],
        districtOfficeArr:[],
        currentTypeData:[],
        secondParkArr:[],
        secondIndustryData:[],
        editType:'',
        secIndustryData:[],
        qualificationTagData: [],
        industryData:[],
        industryTagData:[],
        opeStatusData:[{
          id:'5',
          name:'存续'
        },{
          id:'6',
          name:'在业'
        },{
          id:'7',
          name:'吊销'
        },{
          id:'9',
          name:'迁入'
        },{
          id:'10',
          name:'存续'
        },{
          id:'11',
          name:'迁出'
        },{
          id:'12',
          name:'停业'
        },{
          id:'13',
          name:'清算'
        }],
        title:"操作",
        visible: false,
        accept: 'image/*',
        fileList:[],
        model: {},
        labelCol: {
          xs: { span: 24 },
          sm: { span: 8 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 15 },
        },
        confirmLoading: false,
        form: this.$form.createForm(this),
        validatorRules:{
        companyid:{rules: [{ required: true, message: '请输入公司ID!' }]},
        companycode:{rules: [{ required: true, message: '请输入统一信用代码!' }]},
        companyname:{rules: [{ required: true, message: '请输入公司全称!' }]},
        companyabbr:{rules: [{ required: true, message: '请输入公司简称!' }]},
        companybrief:{rules: [{ required: true, message: '请输入一句话简介!' }]},
        legalperson:{rules: [{ required: true, message: '请输入法人!' }]},
        registeredamt:{rules: [{ required: true, message: '请输入注册资本!' }]},
        paidinamt:{rules: [{ required: true, message: '请输入实缴资本!' }]},
        businessscope:{rules: [{ required: true, message: '请输入经营范围!' }]},
        registereddate:{rules: [{ required: true, message: '请输入成立日期!' }]},
        highteckparkid:{rules: [{ required: true, message: '请输入所属园区!' }]},
        cityid:{rules: [{ required: true, message: '请输入所在城市!' }]},
        registereddistrictid:{rules: [{ required: true, message: '请输入注册区/县!' }]},
        registeredaddress:{rules: [{ required: true, message: '请输入注册详细地址!' }]},
        officedistrictid:{rules: [{ required: true, message: '请输入办公区/县!' }]},
        officeaddress:{rules: [{ required: true, message: '请输入办公详细地址!' }]},
        isregoffsame:{rules: [{ required: true, message: '请输入办公与注册是否一致!' }]},
        operationstatusid:{rules: [{ required: true, message: '请输入经营状态!' }]},
        industryid:{rules: [{ required: true, message: '请输入所属行业!' }]},
        industrytagid:{rules: [{ required: true, message: '请输入行业标签!' }]},
        ishigtech:{rules: [{ required: true, message: '请输入是否高新企业!' }]},
        isbp:{rules: [{ required: true, message: '请输入是否有BP!' }]},
        teamtag:{rules: [{ required: true, message: '请输入团队标签!' }]},
        teamremark:{rules: [{ required: true, message: '请输入团队描述!' }]},
        staffsizeid:{rules: [{ required: true, message: '请输入人员规模!' }]},
        taxedsizeid:{rules: [{ required: true, message: '请输入纳税规模!' }]},
        valuationsizeid:{rules: [{ required: true, message: '请输入估值规模!' }]},
        refinanceroundid:{rules: [{ required: true, message: '请输入融资轮次!' }]},
        interactivecycleid:{rules: [{ required: true, message: '请输入互动周期!' }]},
        servicestatusid:{rules: [{ required: true, message: '请输入服务状态!' }]},
        linkerid:{rules: [{ required: true, message: '请输入Linker!' }]},
        updatebyid:{rules: [{ required: true, message: '请输入最近更新人!' }]},
        ts:{rules: [{ required: true, message: '请输入最近更新日期!' }]},
        datastatus:{rules: [{ required: true, message: '请输入状态!' }]},
        interactivetag:{rules: [{ required: true, message: '请输入互动标签!' }]},
        },
        parkArr:[],
        cityArr:[],
        districtArr:[],
        personData:[],
        provinceData: [],
        cityArrZc: [],
        IndusParkList: [],
        ParkTypeArr: [],
        url: {
          add: "/companyInfo/add",
          edit: "/companyInfo/update",
          baseList:"/baseInfo/queryRows",
          updateFile:"/oss/upload"
        },
      }
    },
    created () {
      this.getProvince();
      // this.getCity();
      this.getBaseData();
      // this.getParkFirst();
      this.getIndustry();
      this.getIndustryTag();
      this.getIndusPark();
    },
    methods: {
      getIndusPark(){
        this.IndusParkList = []
        this.$http.postAction("/baseIndustrialPark/queryRows",{pageIndex:1,pageSize:9999,selectFields:[]}).then(res=>{
          if(res.status == 1){
            this.IndusParkList = res.data.rows;
          }
        })
      },
      getData(){
        this.isLoadingData = true
        let data = this.form.getFieldsValue();
        this.$message.success('正在获取数据，请稍等');
        axios.get('http://localhost:8901/ai/company/industries?company='+data.CompanyName).then(res=> {
          this.isLoadingData = false
          if(res && res.data && res.data.status == 1 && res.data.data){
            let obj = Object.assign(data, res.data.data)
            this.form.setFieldsValue({
              ...obj
            })
          }
        }).catch(res=>{
          this.$message.success('本机未安装服务');
          this.isLoadingData = false
        })
      },
      showCommonUserModal () {
        this.$refs.commonModalUser.open()
      },
      commonModalDataUser(val){
        this.form.setFieldsValue({
          LegalPerson:val[0].PersonalName
        })
      },
      getCityZc(type) {
        this.$nextTick(()=>{
          this.getParkFirst(type)
          let data = this.form.getFieldsValue();
          if(type !== 'init'){
            this.form.setFieldsValue({
              CityId:'',
              RegisteredDistrictId:''
            })
            this.districtArr = []
          }
          
          this.cityArrZc = [];
          let provinceid = data.ProvinceId;
          this.$http.postAction("/baseRegion/queryRows",{pageIndex:1,pageSize:9999,selectFields:[],conditions:[{
              "field":"Parent",
              "operator":"=",
              "value":provinceid
            }]}).then(res=>{
            if(res.status == 1){
              this.cityArrZc = res.data.rows;
              if(type !== 'init'){
                this.getDistrict();
              }
            }
          })
        })
      },
      getProvince(){
        this.$http.postAction("/baseRegion/queryRows",{pageIndex:1,pageSize:9999,selectFields:[],conditions:[{
              "field":"RegionType",
              "operator":"=",
              "value":1
            }]}).then(res=>{
          if(res.status == 1){
            this.provinceData = res.data.rows;
          }
        })
      },
      deleteFileObj(index){
        this.fileList = [];
        this.form.setFieldsValue({
            CompanyLogo: '',
        })
      },
      uploadPic(fileArr){
        if(!this.url.updateFile){
          return false;
        }
        let httpurl = this.url.updateFile;
        let formData = new FormData();
        // for(let i=0;i<fileArr.length;i++){
        //   formData.append('file',fileArr[i])
        // }
        formData.append('file',fileArr)
        let that = this;
        this.fileList = [];
        that.form.setFieldsValue({
            CompanyLogo: '',
        })
        this.$http.postAction(httpurl,formData).then((res)=>{
          if(res.name){
            that.$message.success('上传成功');
            that.form.setFieldsValue({
                CompanyLogo: JSON.stringify(res),
            })
            this.fileList.push({url:res.downloadUrl})
            console.log('ssss',this.fileList)
          }else{
            that.$message.warning(res.message);
          }
        })
      },
      findCode(){
        this.$nextTick(()=>{
          let data = this.form.getFieldsValue();
          let arr = [];
          if(data.CompanyCode){
            arr.push({"field":"CompanyCode",
              "operator":"=",
              "value":data.CompanyCode
            });
          }else if(data.CompanyName){
            arr.push({"field":"CompanyName",
              "operator":"=",
              "value":data.CompanyName
            });
          }
          this.$http.postAction('/companyInfo/queryRows',{pageNo:1,pageSize:1,selectFields:[],conditions:{OR:arr}}).then(res=>{
              if(res.status == 1 && 0 < res.data.rows.length){
                if(res.data.rows[0].CompanyId == this.model.CompanyId){
                  return
                }
                this.$message.warning('信用代码或公司全称重复录入');
              }
            })
        })
        
      },
      filterOption(input, option) {
        return (
          option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
        );
      },
      getSecondPark(type){
        this.$nextTick(()=>{
          let data = this.form.getFieldsValue();
          if(type !== 'init'){
            this.form.setFieldsValue({
              SubParkId:''
            })
          }
          this.$http.postAction('/baseHighteckPark/queryRows',{pageNo:1,pageSize:9999,selectFields:[],conditions:[{
              "field":"ParkType",
              "operator":"=",
              "value":data.HighteckParkId?data.HighteckParkId:this.model.HighteckPark
            }]}).then((res)=>{
            if(res.status == 1){
              this.secondParkArr = res.data.rows;
            }
          })
        })
      },
      getErjiIndustry(type){
        this.$nextTick(()=>{
          let data = this.form.getFieldsValue();
          if(type !== 'init'){
            this.form.setFieldsValue({
              IndustryId: '',
              SubIndustry:[]
            })
          }
          this.$http.postAction('/baseIndustry/queryRows',{pageNo:1,pageSize:9999,selectFields:[],conditions:[{
              "field":"UpIndustry",
              "operator":"=",
              "value":data.PrimaryIndustryId?data.PrimaryIndustryId:this.model.PrimaryIndustryId
            }]}).then((res)=>{
            if(res.status == 1){
              this.secIndustryData = res.data.rows;
            }
          })
        })
        
      },
      getSecondIndustry(type){
        this.$nextTick(()=>{
          let data = this.form.getFieldsValue();
          if(type !== 'init'){
            this.form.setFieldsValue({
              SubIndustry:[]
            })
          }
          this.$http.postAction('/baseIndustry/queryRows',{pageNo:1,pageSize:9999,selectFields:[],conditions:[{
              "field":"UpIndustry",
              "operator":"=",
              "value":data.IndustryId?data.IndustryId:this.model.Industry
            }]}).then((res)=>{
            if(res.status == 1){
              this.secondIndustryData = res.data.rows;
            }
          })
        })
        
      },
      getBaseData(){
        this.$http.postAction(this.url.baseList,{pageNo:1,pageSize:100,selectFields:[],conditions:[{
              "field":"TypeCode",
              "operator":"=",
              "value":'QualificationTag'
            }]}).then((res)=>{
          if(res.status == 1){
            this.qualificationTagData = res.data.rows;
          }
        })
        this.$http.postAction(this.url.baseList,{pageNo:1,pageSize:100,selectFields:[],conditions:[{
              "field":"TypeCode",
              "operator":"=",
              "value":'OperationStatus'
            }]}).then((res)=>{
          if(res.status == 1){
            this.opeStatusData = res.data.rows;
          }
        })
        this.$http.postAction(this.url.baseList,{pageNo:1,pageSize:100,selectFields:[],conditions:[{
              "field":"TypeCode",
              "operator":"=",
              "value":'CurrencyType'
            }]}).then((res)=>{
          if(res.status == 1){
            this.currentTypeData = res.data.rows;
          }
        })
        this.$http.postAction(this.url.baseList,{pageNo:1,pageSize:100,selectFields:[],conditions:[{
              "field":"TypeCode",
              "operator":"=",
              "value":'ParkType'
            }]}).then((res)=>{
          if(res.status == 1){
            this.ParkTypeArr = res.data.rows;
          }
        })
      },
      changeCity(){
        this.getDistrict();
      },
      changeOfficeCity(){
        this.getOfficeDistrict();
      },
      getIndustry(){
        this.$http.postAction('/baseIndustry/queryRows',{pageNo:1,pageSize:9999,selectFields:[],conditions:[{
              "field":"UpIndustry.Industry",
              "operator":"IS NULL",
              "value":""
            }]}).then((res)=>{
          if(res.status == 1){
            this.industryData = res.data.rows;
          }
        })
      },
      getIndustryTag(type){
        this.$nextTick(()=>{
          let data = this.form.getFieldsValue();
          if(type !== 'init'){
            this.form.setFieldsValue({
              IndustryTagId:[]
            })
          }
          this.$http.postAction('/baseIndustryTag/queryRows',{pageNo:1,pageSize:9999}).then((res)=>{
            if(res.status == 1){
              this.industryTagData = res.data.rows;
            }
          })
        })
        
      },
      getParkFirst(type){
        this.$nextTick(()=> {
          let data = this.form.getFieldsValue();

          if (!data.ProvinceId || !data.HighteckParkId) {
            return
          }
          if(type !== 'init'){
            this.form.setFieldsValue({
              SubParkId: ''
            })
          }
          this.$http.postAction("/baseHighteckPark/queryRows",{pageIndex:1,pageSize:9999,conditions:[{
              "field":"Region",
              "operator":"=",
              "value":data.ProvinceId
            },{
              "field":"ParkType",
              "operator":"=",
              "value":data.HighteckParkId
            }]}).then(res=>{
            if(res.status == 1){
              this.parkArrFirst = res.data.rows;
            }
          })
          // this.$http.postAction(this.url.baseList,{pageNo:1,pageSize:100,selectFields:[],conditions:[{
          //     "field":"TypeCode",
          //     "operator":"=",
          //     "value":'ParkType'
          //   }]}).then(res=>{
          //   if(res.status == 1){
          //     this.parkArrFirst = res.data.rows;
          //   }
          // })
        })
        
      },
      getPark(){
        this.$http.postAction("/baseHighteckPark/queryRows",{pageIndex:1,pageSize:9999}).then(res=>{
            if(res.status == 1){
              this.parkArr = res.data.rows;
            }
          })

      },
      getCity(type){
        this.$nextTick(()=>{
          let data = this.form.getFieldsValue();
          if(type !== 'init'){
            this.form.setFieldsValue({
              OfficeCityId:'',
              OfficeDistrictId:''
            })
            this.districtOfficeArr = [];
          }
          
          this.cityArr = [];
          let provinceid = data.OfficeProvinceId;
          this.$http.postAction("/baseRegion/queryRows",{pageIndex:1,pageSize:9999,selectFields:[],conditions:[{
              "field":"Parent",
              "operator":"=",
              "value":provinceid
            }]}).then(res=>{
            if(res.status == 1){
              this.cityArr = res.data.rows;
              if(type == 'init'){
                this.getOfficeDistrict('init');
              }
            }
          })
        })
        // this.$http.postAction("/baseRegion/queryRows",{pageIndex:1,pageSize:9999,selectFields:[],conditions:[{
        //       "field":"RegionType",
        //       "operator":"=",
        //       "value":2
        //     }]}).then(res=>{
        //     if(res.status == 1){
        //       this.cityArr = res.data.rows;
        //       let cityId = '';
        //     }
        //   })
      },
      getOfficeDistrict(type){
        this.$nextTick(()=>{
          let data = this.form.getFieldsValue();
          let parentId = data.OfficeCityId;
          if(!parentId){
            return false;
          }
          if(type !== 'init'){
            this.form.setFieldsValue({
              OfficeDistrictId:''
            })
          }

          this.districtOfficeArr = [];
          this.$http.postAction("/baseRegion/queryRows",{pageIndex:1,pageSize:9999,selectFields:[],conditions:[{
                "field":"Parent",
                "operator":"=",
                "value":parentId
              }]}).then(res=>{
              if(res.status == 1){
                this.districtOfficeArr = res.data.rows;
              }
            })
        })
      },
      getDistrict(type){
        this.$nextTick(()=>{
          let data = this.form.getFieldsValue();
          let parentId = data.CityId;
          if(!parentId){
            return false;
          }
          if(type !== 'init'){
            this.form.setFieldsValue({
              RegisteredDistrictId:''
            })
          }
          this.districtArr = [];
          this.$http.postAction("/baseRegion/queryRows",{pageIndex:1,pageSize:9999,selectFields:[],conditions:[{
                "field":"Parent",
                "operator":"=",
                "value":parentId
              }]}).then(res=>{
              if(res.status == 1){
                this.districtArr = res.data.rows;
              }
            })
        })
      },
      add () {
        let id = '';
        this.cityArr.forEach((e)=>{
          if(e.RegionName == '上海市'){
            id = e.RegionId
          }
        })
        let OperationStatuId = '';
        this.opeStatusData.forEach((e)=>{
          if(e.Value == '在业'){
            OperationStatuId = e.BaseInfoId
          }
        })
        this.edit({City:id,OperationStatusId:OperationStatuId});

      },
      edit (record) {
        this.form.resetFields();
        this.model = Object.assign({}, record);
        this.visible = true;
        this.fileList = [];
        if(this.model.CompanyId){
          
            this.$http.postAction("/companyInfo/detail/map",this.model.CompanyId,{
            headers: {
              "Content-type": "application/text"
            }
           }).then(res=>{
              if(res.status == 1){
                res.data.CompanyId = this.model.CompanyId;
                this.model = res.data?res.data:{};
                delete this.model.RegisteredPeriod;
                delete this.model.IsHigtech;
                delete this.model.IsBp;
                delete this.model.TeamTag;
                delete this.model.StaffSize;
                delete this.model.TaxedSize;
                delete this.model.ValuationSize;
                delete this.model.RefinanceRound;
                delete this.model.InteractiveCycle;
                delete this.model.InteractiveTag;
                delete this.model.DemandTag;
                // this.model.IndustryId = this.model.Industry;
                this.model.IndustryTagId = this.model.IndustryTag?this.model.IndustryTag.split(','):[];
                this.model.QualificationTag = this.model.QualificationTag?JSON.parse(this.model.QualificationTag):[];
                // this.model.OperationStatusId = this.model.OperationStatus;
                // this.model.CityId = this.model.City;
                // this.model.OfficeDistrictId = this.model.OfficeDistrict;
                // this.model.RegisteredDistrictId = this.model.RegisteredDistrict;
                // this.model.ProvinceId = this.model.ProvinceId?this.model.ProvinceId:'';
                // this.model.OfficeProvinceId = this.model.ProvinceId?this.model.ProvinceId:'';
                this.model.HighteckParkId = this.model.HighteckPark?this.model.HighteckPark.BaseInfoId:'';
                this.model.SubParkId = this.model.SubPark?this.model.SubPark.Id:'';
                this.model.SubIndustryId = this.model.SubIndustry?this.model.SubIndustry.split(','):[];
                this.model.SubIndustry = [];
                if(this.model.SubIndustries){
                  this.model.SubIndustries.forEach((e)=>{
                    this.model.SubIndustry.push(e.SubIndustryId)
                  })
                }
                if(this.model.CompanyLogo){
                  this.fileList.push({url:JSON.parse(this.model.CompanyLogo).downloadUrl})
                }
                // this.model.CurrencyTypeId = this.model.CurrencyType;
              }
              this.$nextTick(() => {
                this.form.setFieldsValue(pick(this.model,'CompanyCode','CompanyName','CompanyAbbr','CompanyBrief','LegalPerson','RegisteredAmt','PaidinAmt','HighteckParkId','CityId','OfficeCityId','RegisteredDistrictId','RegisteredAddress','OfficeDistrictId','OfficeAddress','OperationStatusId','IndustryId','IndustryTagId','TeamRemark','CompanyDepiction','SubIndustry','SubParkId','CurrencyTypeId','CompanyLogo', 'ProvinceId', 'OfficeProvinceId','PrimaryIndustryId', 'QualificationTag', 'IndustrialParkId'))
                this.getCityZc('init');
                this.getCity('init');
                this.getDistrict('init');
                this.getOfficeDistrict('init');
                this.getErjiIndustry('init')
                this.getSecondIndustry('init');
                //时间格式化
                this.form.setFieldsValue({RegisteredDate:this.model.RegisteredDate?moment(this.model.RegisteredDate,'YYYY-MM-DD HH:mm:ss'):null})
                })
                this.changePark();
              }); 
              
              this.getSecondPark('init'); 
              
        }else{
          this.$nextTick(() => {
            this.form.setFieldsValue(pick(this.model,'CompanyCode','CompanyName','CompanyAbbr','CompanyBrief','LegalPerson','RegisteredAmt','PaidinAmt','HighteckParkId','CityId','RegisteredDistrictId','RegisteredAddress','OfficeDistrictId','OfficeAddress','OperationStatusId','IndustryId','IndustryTagId','TeamRemark','CompanyDepiction','SubIndustry','SubParkId','CurrencyTypeId','CompanyLogo', 'ProvinceId', 'OfficeProvinceId','PrimaryIndustryId', 'QualificationTag','IndustrialParkId'))
            this.getDistrict('init');
            
            //时间格式化
            this.form.setFieldsValue({RegisteredDate:this.model.RegisteredDate?moment(this.model.RegisteredDate,'YYYY-MM-DD HH:mm:ss'):null})
          });
        }                                        
      },
      close () {
        this.$emit('close');
        this.visible = false;
      },
      changePark(){
        this.$nextTick(()=>{
          let data = this.form.getFieldsValue();
          let name = '';
          if(data.SubParkId){
            console.log('ffffg',this.parkArr)
            this.parkArr.forEach((e)=>{
              if(e.BaseHighteckParkId == data.SubParkId){
                name = e.ParkType_Value;
              }
            })
          }
          this.form.setFieldsValue({
            ParkTypeName:name,
            SubPark:null
          })
        })
      },
      handleSave(){
        const that = this;
        // 触发表单验证
        this.form.validateFields((err, values) => {
          if (!err) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.CompanyId){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            let formData = Object.assign(this.model, values);
            //时间格式化
            formData.RegisteredDate = formData.RegisteredDate?formData.RegisteredDate.format('YYYY-MM-DD HH:mm:ss'):null;
            formData.IndustryTagId = formData.IndustryTagId instanceof Array?formData.IndustryTagId.join():formData.IndustryTagId;
            formData.QualificationTag = formData.QualificationTag instanceof Array?formData.QualificationTag.join():formData.QualificationTag;
            formData.SubIndustry = formData.SubIndustry instanceof Array?formData.SubIndustry.join():formData.SubIndustry;
            let arr = [];
            if(formData.SubParkId){
              console.log('ffff',this.parkArr)
              this.parkArr.forEach((e)=>{
                if(e.BaseHighteckParkId == formData.SubParkId){
                  formData.ParkTypeId = e.ParkType;
                }
              })
            }
            formData.SubIndustry.split(',').forEach((e)=>{
              arr.push({
                SubIndustryId:e
              })
            })
            // if(formData.Investor instanceof Array){
            //   formData.Investor.forEach(e=>{
            //     formData.Investors.push({InvestorId:e});
            //   })
            // }else{
            //   if(formData.Investor){
            //     formData.Investors.push({InvestorId:formData.Investor});
            //   }
            // }
            formData.SubIndustries = arr;
            formData.SubPark = null;
            delete formData.PrimaryIndustry
            formData.PrimaryIndustryId = formData.PrimaryIndustryId ? formData.PrimaryIndustryId : null
            console.log(formData)
            this.$http.postAction(httpurl,formData,method).then((res)=>{
              if(res.status == 1){
                that.$message.success('提交成功');
                if(method == 'post'){
                  this.form.resetFields();
                  this.model = {};
                }else{
                  // that.close();
                }
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
              // that.close();
            })



          }
        })
      },
      handleOk () {
        const that = this;
        // 触发表单验证
        this.form.validateFields((err, values) => {
          if (!err) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.CompanyId){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            let formData = Object.assign(this.model, values);
            //时间格式化
            formData.RegisteredDate = formData.RegisteredDate?formData.RegisteredDate.format('YYYY-MM-DD HH:mm:ss'):null;
            formData.IndustryTagId = formData.IndustryTagId instanceof Array?formData.IndustryTagId.join():formData.IndustryTagId;
            formData.SubIndustry = formData.SubIndustry instanceof Array?formData.SubIndustry.join():formData.SubIndustry;
            let arr = [];
            if(formData.SubParkId){
              console.log('ffff',this.parkArr)
              this.parkArr.forEach((e)=>{
                if(e.BaseHighteckParkId == formData.SubParkId){
                  formData.ParkTypeId = e.ParkType;
                }
              })
            }
            if(formData.SubIndustry){
              formData.SubIndustry.split(',').forEach((e)=>{
                arr.push({
                  SubIndustryId:e
                })
              })
            }
            formData.SubIndustries = arr;
            formData.SubPark = null;
            delete formData.PrimaryIndustry
            formData.PrimaryIndustryId = formData.PrimaryIndustryId ? formData.PrimaryIndustryId : null
            console.log(formData)
            this.$http.postAction(httpurl,formData,method).then((res)=>{
              if(res.status == 1){
                that.$message.success('提交成功');
                if(method == 'post'){
                  this.form.resetFields();
                  this.model = {};
                }else{
                  that.close();
                }
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
              // that.close();
            })



          }
        })
      },
      handleCancel () {
        this.close()
      },


    }
  }
</script>

<style lang="less" scoped>

</style>
<style>
  .labelColMax .ant-form-item-label{
    width: 107px;
    float: left;
  }
  .labelColMax .ant-form-item-control-wrapper{
    width: calc(100% - 120px);
    display: inline-block;
  }
  .labelColMid .ant-form-item-label{
    width: 107px;
    float: left;
  }
  .labelColMid .ant-form-item-control-wrapper{
    width: calc(100% - 120px);
    display: inline-block;
  }
</style>